package com.example.factory.core.service.impl;

import com.example.factory.core.domain.Equipment;
import com.example.factory.core.repository.EquipmentRepository;
import com.example.factory.core.service.EquipmentService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * @author Lei Tao
 */
@Service
public class EquipmentServiceImpl implements EquipmentService {
    private final EquipmentRepository equipmentRepository;

    public EquipmentServiceImpl(EquipmentRepository equipmentRepository) {
        this.equipmentRepository = equipmentRepository;
    }

    @Override
    @Transactional
    public void deleteEquipment(Equipment equipment) {
        equipment.archived();
        equipmentRepository.save(equipment);
    }

    @Override
    public void save(Equipment equipment) {
        equipmentRepository.save(equipment);
    }
}
